<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>公众号自定义菜单设置</title>
</head>

<body>
<?php

//$appid  = 'wx234ccba5ec69a5cf';
//$appid  = 'wx19c6fc19e33c01d2';
//
//$secret = '453b833967f156b43aadde6aad1f7951';
//$secret = 'd4624c36b6795d1d99dcf0547af5443d';


$appid  =  'wxf6f0d8764ddf2176';
$secret =  '03d684e2d937a9df9fd0f94df9c901b3';


$token = 'weiphp';

$url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=".$appid."&secret=".$secret;
$content = file_get_contents($url);
$info = json_decode($content);
$ACCESS_TOKEN=$info->access_token;
//"url":"https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxc8a7584bdc331e27&redirect_uri=http%3a%2f%2fhq.zjgsu.edu.cn%2fordertest%2fEntryServlet&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect" 


$nav_url = "https://api.weixin.qq.com/cgi-bin/menu/create?access_token=".$ACCESS_TOKEN;
$data = ' {
     "button":[
      {
           "name":"教学平台",
           "sub_button":[
			{
               "type":"view",
               "name":"主页",
               "url":"http://8080.mysunner.applinzi.com/index.php/Home/Team/index"
            }]
     },
      {
           "name":"个人中心",
           "sub_button":[
            {
               "type":"view",
               "name":"互动娱乐",
               "url":"http://www.baidu.com/"
            },
			{	
               "type":"click",
               "name":"我的记录",
               "key":"huoche_cx"
            },
            {
               "type":"click",
               "name":"签到积分",
               "key":"kuaidi_cx"
            }]
       }]
 }';

post($nav_url,$data);


function post($url, $jsonData){
	$ch = curl_init($url) ;
	curl_setopt($ch, CURLOPT_POST, 1);
	curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
	curl_setopt($ch, CURLOPT_POSTFIELDS,$jsonData);
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
	curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
	
	$result = curl_exec($ch) ;
	curl_close($ch) ;
	echo $result;
}

?>
</body>
</html>